package com.parachutes.aspinterfacecore.controller;

import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.parachutes.aspinterfaceapi.domain.Result;
import com.parachutes.aspinterfaceapi.domain.SysUserEarnings;
import com.parachutes.aspinterfaceapi.service.SysUserEarningsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/earnings")
public class SysUserEarningsController {
    @Autowired
    private SysUserEarningsService sysUserEarningsService;

    @GetMapping("/list")
    public Result<?> getUserEarnings(Integer page, Integer pageSize) {
        PageMethod.startPage(page, pageSize);
        List<SysUserEarnings> list = sysUserEarningsService.getUserEarnings((page - 1) * pageSize, pageSize);
        PageInfo<SysUserEarnings> pageInfo = new PageInfo<>(list);
        return Result.of(true, "获取成功", pageInfo);
        }
}
